package com.yesep.learn.design.behavioral.iterator;

import com.yesep.learn.design.common.pojo.*;

import java.util.*;

public class GoodsIteratorImpl implements IIterator<Goods> {
    private final List<Goods> list;
    private int position = 0;

    public GoodsIteratorImpl(List<Goods> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        return position < list.size();
    }

    @Override
    public Goods next() {
        Goods current = list.get(position);
        position++;
        return current;
    }
}
